package com.example.sample.controller;

import com.example.sample.Infrastructure.Model.Command.OrderChangeCompleteCommand;
import com.example.sample.Infrastructure.Model.Enum.PaymentType;
import com.example.sample.Infrastructure.Model.ViewModel.OrderChangeBasicInfoViewModel;
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
import org.hibernate.loader.plan.spi.Return;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;

@org.springframework.web.bind.annotation.RestController()
@RequestMapping("/rest")
public class RestController {

    @Autowired
    private RestTemplate RestTemplate;

    @GetMapping("")
    public OrderChangeBasicInfoViewModel Get() {

        OrderChangeBasicInfoViewModel result = RestTemplate.getForObject("http://localhost:5020/orders/v1/OrderChange/base/{id}", OrderChangeBasicInfoViewModel.class, "ucm06l3tl3wg");

        return result;
    }

    @GetMapping("post")
    public void Post() {

        OrderChangeCompleteCommand cmd = new OrderChangeCompleteCommand("ucog09r7uj9c",10, "2021-02-21", "2021-02-21",PaymentType.BalancePaymentReceiveRefund,"德玛西亚","附件");

        RestTemplate.postForObject("http://localhost:5020/orders/v1/OrderChange/complete", cmd, Object.class);
    }
}
